[ Intro ]   [ Lesson1 ]   [ Lesson2 ]   [ Lesson3 ]   [ Lesson4 ]   [ Lesson5 ]   [ Lesson6 ]   [ Lesson7 ]   [ Lesson8 ]

 


Before out first script

Firstly we should check out a few settings in Scriptor to see if it's installed ok. Load the program and go to in the menu to Compile/Script, or push Alt + F7.

Check the include directory is set to 'wherever_you_installed_Scriptor\Include\', e.g. 'C:\Games\TA\unitmaking\Scriptor\Include\'
Now check the constants. Linear should be 163840.0, and Angular should be 182.0.
Game option is Total Annihilation. Output options are both with 'Same as bos' boxes checked.

Now, we'll be dealing with two file types: .bos and .cob. Don't worry, this isn't twice the work, it's simply that .bos is the text version of the script we'll be editing, and .cob is the compiled version that TA uses. Scriptor will have probably allocated .bos it's own icon, but this can cause a problem. If you find you can't compile any scripts after double-clicking them to open them in Scriptor, simply load Scriptor first and open them into it.


Now for our first script

Some TA units can be quite complex. There will often be a whole new function for every effect ingame, such as aiming weapons, moving lags, even ship wakes. The simplest unit to start with would be a weaponless unit with no special movement animations. Now open the first example script into Scriptor, example1.bos.


Piece ;

example

piece base ,body ;

First thing in a .bos file will often be as in this one, the piece list. We have to declare the names of all model objects/pieces we intent to animate in TA. The pieces are names of the different parts in your 3D model, arranged under a tech tree. If we have a unit with just the groundplate piece (often called base), and a body piece, it would look as our example does.

Note the ; at the end. Scriptor can detect if you've missed one of these from you script, but sometimes it won't, or the error won't be clear that this is the problem. All but a few lines will end with one of these.

More info:

master/slave

 


Static-var ;

example

static-var number ;

Next we declare the names of then variables we will be using to control actions. This is our static-var line. Sometimes either piece or static-var lines are very long, and wrap around to the next line. If you want to avoid this, end one with a ; and start the next with piece or static-var again. This means that every time you will want to store numbers to calculate with, you must tell the program what you want to use as such storage.


Create()

example

Create()
{
number = 1;
}

This is how a function is listed in TA. The name is given, as well as any variables/parameters to be passed to this function within the ( ), as shall be seen later. The contents is then encapsulated in { and }. Both types of line do not end with a semicolon ";".

More info:

Equal signs

Semicolons

Every unit in TA uses this function as soon as something starts to build it, before it's complete and selectable (or converted to a Dragon's Tooth). In here you should declare the starting states of every variable you will be using, as well as hiding weapon flares and starting other animations.


SweetSpot(piecenum)

example

SweetSpot(piecenum)
{
piecenum = body;
}

his is another function every TA unit should have. This time we're passed a variable, which this function calls piecenum. This variable is only used within this function, so other functions may have variables with the same name but different values. The static-vars we listed earlier are used by all of the script, and only have one value at any instance

In this case, the TA engine will call this function and awaits the name of the piece to be used as the sweetspot. This is the piece that enemy weapons will try to aim at when firing. To set a moving part as a piecenum makes it . This is not the piece which will cause damage to your unit if hit, that's the groundplate. Usually the sweetspot is defined as the groundplate/base, or the first branch object in the model object tree, and normally only child of the groundplate (in this case it's body, sometimes the pelvis if a walking k-bot for example).

This is all we need in a basic .bos file for a simple unit. Note we didn't even use var1, but I've included it in this example to help explain variables. Now click the Bos -> Cob button, select Compile, Compile from the menu, or push Ctrl + F7. Scriptor will now attempt to covert this text .bos file into a .cob. You will see in the bottom left area something like:

 

Compiling BOS...

Making COB...
Wrote C:\Games\TA\unitmaking\Proud's Scripting guide\examples\example1.cob


Congratulations, you've just made a complete TA script file. If you've had any errors, make sure you didn't edit anything, and then contact me, the best way being via the TAUniverse.com forums, where I am co-moderator of the Unit forums. Otherwise, onward to Lesson2.


© Proud like a god (and a little Storm)